package com.example.translate;

import com.transn.sdk.config.TransnAuth;
import com.transn.sdk.contant.TranslateLanguageEnum;
import com.transn.sdk.dto.TextMachineTranslateDTO;
import com.transn.sdk.service.TransnMtService;

/**
 * 传神文本机翻
 *
 * @author 王振【wosen.wang@woordee.com】
 * @version 2019-09-12 16:44
 */
public class TransnTextTranslate {

    private final static String appKey = "yuyi";

    private final static String appSecret = "6911c91feef24845bdfc08e0b407f349";

    private TransnTextTranslate() {

    }

    private static TransnMtService transnMtService = new TransnMtService(new TransnAuth(appKey, appSecret));

    public static String machineTranslate(String srcLan, String tarLan, String content) {
        TextMachineTranslateDTO dto = new TextMachineTranslateDTO();
        dto.setContent(content);
        dto.setSrcLanguage(TranslateLanguageEnum.getLanguageByCode(srcLan));
        dto.setTarLanguage(TranslateLanguageEnum.getLanguageByCode(tarLan));
        return transnMtService.textTranslate(dto);
    }

    public static void main(String[] args) {
        try {
            String content = "There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! Dream what you want to dream;go where you want to go;be what you want to be,because you have only one life and one chance to do all the things you want to do";
            System.out.println(machineTranslate("en", "zh", content));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
